#ifndef __TwSampleApplication_H__
#define __TwSampleApplication_H__

#include "TwApplicationHeaders.h"
#include "TwFps.h"
#include "TwBrush.h"
#include "TwAvatar.h"
#include "TwNameBoard.h"
#include "TwGUI.h"

class TwSampleApplication : public TwApplication
{
public:
	TwSampleApplication();

	virtual void terminate();
	virtual void update();
	virtual void renderScene();
	virtual void endRender();

	void pickTerrain(float screenx, float screeny);
	void pickEntities(float screenx, float screeny);
	void toggleFillMode();
	void toggleCamera();
	void saveScreen();

	bool OnGUIEventSheetMouseMove(const TwGUI::EventArgs& args);
	bool OnGUIEventSheetLButtonDown(const TwGUI::EventArgs& args);

	bool OnGUIEventToggleFpsWnd(const TwGUI::EventArgs& args);
	bool OnGUIEventToggleSatyrPortrait(const TwGUI::EventArgs& args);
	bool OnGUIEventToggleOrcWnd(const TwGUI::EventArgs& args);
	
	bool OnGUIEventPause(const TwGUI::EventArgs& args);
	bool OnGUIEventResume(const TwGUI::EventArgs& args);

	bool OnGUIEventMouseEnter(const TwGUI::EventArgs& args);
	bool OnGUIEventMouseLeave(const TwGUI::EventArgs& args);

protected:
	virtual bool createScene();

	bool _setupContent();
	void _cleanupContent();
	bool _setupEntities();
	bool _setupRPGCamera();
	void _updateRPGCamera();
	bool _setupGUI();
	bool _setupGUIWidgets();
	bool _setupGUICursor();
	void _cleanupGUI();

	virtual void _renderScreenTwements();

	void _saveScreenImp(LPCSTR directory);

protected:
	D3DXVECTOR3			m_mTerrainIntersectedPoint;
	TwGameObject*		m_mSceneIntersectedObject;

	bool				m_mSaveScreenAfterRendered;

	TwBrush				m_mBrush;

	TwNameboard			m_mSatyrNameboard;
	TwNameboard			m_mTigerNameboard;

	TwCamera*			m_mRPGCamera;
	TwSceneNode*		m_mCameraPivot;
	TwSceneNode*		m_mCameraGoal;
	TwSceneNode*		m_mCameraNode;
	TwSceneNode*		m_mFirstPersonNode;

	TwGUI::Renderer*	m_mGUIRenderer;
	TwGUI::System*		m_mGUISystem;

	TwAvatar			m_mAvatar;
	TwGUI::StaticImage*	m_mAvatarWindow;
	TwFps				m_mFps;
	TwGUI::StaticText*	m_mFpsWindow;
};

#endif //__TwSampleApplication_H__